#ifndef I420RENDER_H
#define I420RENDER_H

#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLTexture>
#include <QOpenGLBuffer>
#include <QOpenGLShader>
#include <QOpenGLWidget>

#include "decodevideothread.h"

class I420Render : public QOpenGLWidget,public QOpenGLFunctions
{
    Q_OBJECT
public:
    I420Render(QWidget *parent =nullptr);
    ~I420Render();

    void set_url(QString url);
    void play();
    void stop();

    void initializeGL();        //由界面自动调用，并且只调用一次
    void resizeGL(int w,int h); //在界面大小调整时自动调用
    void paintGL();             //绘制界面刷新时自动调用

private:
    //shader程序
    QOpenGLShaderProgram mProgram;
    //shader中yuv变量地址
    GLuint mTextureUniformY, mTextureUniformU , mTextureUniformV;
    //创建纹理
    GLuint mIdy , mIdu , mIdv;

    int mWidth,mHeight;

    DecodeVideoThread *mDecodeThread;

    uchar* ptr;
};

#endif // I420RENDER_H
